#coding:utf-8
from selenium import webdriver

from Pages.BasePage import BasePage
import time

class LoginPage(BasePage):
    def __init__(self,driver):
        super().__init__(driver)
        self.url = self.yamlreader.get_url("LoginPageconde","login_url")
        self.username = self.yamlreader.get_element("LoginPageconde","username")
        self.password = self.yamlreader.get_element("LoginPageconde","password")
        # self.verfiy_code = self.yamlreader.get_element("LoginPageconde","verfiy_code")
        self.login_button = self.yamlreader.get_element("LoginPageconde","login_button")

    def login(self,username,password):
        self.get(self.url)
        time.sleep(2)
        self.find_element(self.username).send_keys(username)
        self.find_element(self.password).send_keys(password)
        # self.find_element(self.verfiy_code).send_keys(verfiy_code)
        self.find_element(self.login_button).click()

if __name__ == '__main__':
    driver = webdriver.Chrome()
    username = 'fanmao100'
    password = "123456"
    print(LoginPage(driver).login(username=username,password=password))